import { observable, action } from 'mobx';
import { WeaTools } from 'ecCom';
import { WeaForm } from 'comsMobx';

export default class ParticipationStore {
  @observable adSearchForm = new WeaForm();
  @observable adSearchFileds = [];

  // 高级搜索
  @action onGetAdSearchData = (params, callback, needNewForm = true) => {
    WeaTools.callApi(
      '/api/cowork/participation/getCoworkParterShareCondition',
      'GET',
      params,
    ).then(
      action('fetchSuccess', (res) => {
        let condition = res.conditioninfo;
        if (needNewForm) {
          this.adSearchForm = new WeaForm();
        }
        this.adSearchForm.initFormFields(condition);
        this.adSearchFileds = condition;
        if (callback) callback();
      }),
    );
  };
}
